package com.taru.houseapp.service.impl;

import com.taru.houseapp.dao.IOrderDao;
import com.taru.houseapp.entity.Message;
import com.taru.houseapp.entity.Order;
import com.taru.houseapp.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class OrderServiceImpl implements IOrderService {

    @Autowired
    IOrderDao orderDao;

    @Override
    public int insertOrder(Order order) {
        int code=orderDao.insertOrder(order);
        return code;
    }

    @Override
    public List<Order> queryRentInUserOrder(String userId, String code) {

        return orderDao.queryRentInUserOrder(userId,code);
    }

    @Override
    public Order queryRentInUserOrderById(String orderId) {

        return orderDao.queryRentInUserOrderById(orderId);
    }

    @Override
    public int updateOrderIsSuccess(String orderId) {

        return orderDao.updateOrderIsSuccess(orderId);
    }

    @Override
    public int updateOrderIsRentHouse(String orderId) {

        return orderDao.updateOrderIsRentHouse(orderId);
    }

    @Override
    public List<Order> queryOrderByRentOutUser(String userId, String code) {

        return orderDao.queryOrderByRentOutUser(userId,code);
    }

    @Override
    public int updateRentOutIsSuccess(String orderId) {

        return orderDao.updateRentOutIsSuccess(orderId);
    }

    @Override
    public Order queryRentOutUserOrderById(String orderId) {

        return orderDao.queryRentOutUserOrderById(orderId);
    }

    @Override
    public boolean queryOederIsOk(String userId, String houseId) {
        boolean isExist=false;
        Order order=orderDao.queryOederIsOk(userId,houseId);
        if(order!=null){
            isExist=true;
        }
        return isExist;
    }
}
